<template>
	<view class="kedouIntegral ">
		<view class="kedouIntegral_count bg-orange">
			<view class="kedouIntegral_title">
				{{userInfo.kdj}}
			</view>
			<view class="kedouIntegral_desc"  v-if="false">
				今日价格：{{userInfo.today_kdj}}积分/个
			</view>
			<view class="kedouIntegral_ranshao" v-if="false">
				总燃烧量：{{userInfo.rs_Kdj}}
			</view>
			<view style="display: flex;align-items: center;justify-content: space-around;margin-top: 55rpx;">
				<view class="kedouIntegral_button"  @tap="$wanlshop.auth('/pages/user/work/index')" v-if="false">
					誉马庄园
				</view>
				<!--
				<view class="kedouIntegral_button"  @tap="$wanlshop.auth('/pages/user/newTeam/puzzle')">
					拼图游戏
				</view>
				<view class="kedouIntegral_button"  @tap="$wanlshop.auth('/pages/user/newTeam/casting')">
					铸造
				</view>
				-->			
			</view>
			<!-- 转增kdj -->
			<view class="kedouIntegral_zhuan" @click="goTransferkdj">
				转增
			</view>
			<view class="kedouIntegral_zhuan" @click="compose()" style="    margin-top: 50px;">
				合成
			</view>
		</view>
		<view class="newTeam_title">
			明细
		</view>
		<view class="newTeam_centent">
			<view class="newTeam_one" v-for="(item,index) in array" :key="index">
				<view class="newTeam_one_left">
					<view class="newTeam_one_leftActive">
						<view class="leftActive_time">
							{{item.createtime}}
						</view>
						<view class="leftActive_name">
							{{item.memo}}
						</view>
					</view>
				</view>
				<view class="newTeam_one_right">
					{{item.kdj}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	export default {
		data(){
			return {
				userInfo:"",
				page:1,
				last_page:1,
				array:[],
				is_card:'1',
			}
		},
		onShow() {
			this.loadData()
			this.getCard()
			this.getLog('init')
		},
		onPullDownRefresh() {
			setTimeout(()=>{
				uni.stopPullDownRefresh()
			},1500)
			this.getLog('init')
		},
		onReachBottom() {
			if(this.page<this.last_page){
				this.page++
				this.getLog()
			}
		},
		methods:{
			async getCard(){
				await uni.request({
					url:"/index/is_card",
					method:"POST",
					data:{},
					success: (res) => {
						this.is_card=res.data
						// console.log(res.data,'是否隐藏')
					}
				})
			},
			async loadData() {
				await uni.request({
					url: '/wanlshop/user/refresh',
					method: 'POST',
					success: res => {
						this.userInfo=res.data.userinfo
						// console.log(res.data.userinfo,'89999999999999999999999999999999999')
					}
				});
			},
			compose(){
				uni.request({
					url: '/appapi/compose',
					method: 'POST',
					//data:{uid:},
					success: res => {
						app.showMsg(res.msg,"warn");
					}
				});
			},
			goTransferkdj(){
				//this.$wanlshop.auth('/pages/user/newTeam/transferKdj');
				this.$wanlshop.auth('/pages/user/money/transfer_kdj');
				// 判断是否实名人认证
				if(this.userInfo.is_auth==0&&this.is_card==0){
					uni.showModal({
						title:"提示",
						content:"请先实名认证",
						success: (res) => {
							if(res.confirm){
								// console.log('8999999999999999999')
								this.$wanlshop.auth('/pages/user/setting/RealName')
							}
						}
					})
				}else{
					this.$wanlshop.auth('/pages/user/newTeam/transferKdj')
				}
			},
			async getLog(type){
				if(type=='init'){
					this.page=1
					this.array=[]
				}
				await uni.request({
					url:"/wanlshop/user/user_kdj_log",
					method:"POST",
					data:{
						page:this.page
					},
					success: (res) => {
						this.last_page=res.data.last_page
						if(res.data.data.length){
							if(this.page==1){
								this.array=res.data.data
							}else{
								this.array=[...this.array,...res.data.data]
							}
						}
						console.log(res.data,'8999999999999999')
					}
				})
			}
		}
		
	}
</script>

<style lang="scss" scoped>
	.kedouIntegral{
		width: 100%;
		box-sizing: border-box;
		padding: 20rpx 24rpx;
		.kedouIntegral_count{
			width: 100%;
			min-height: 100rpx;
			background-color: #fe6600;
			border-radius: 20rpx;
			box-sizing: border-box;
			padding: 40rpx 0;
			text-align: center;
			position: relative;
			.kedouIntegral_title{
				font-size: 40rpx;
				color: #333333;
				font-weight: 800;
			}
			.kedouIntegral_desc{
				font-size: 35rpx;
				font-weight: 500;
				color: #333333;
				margin-top: 45rpx;
			}
			.kedouIntegral_ranshao{
				font-size: 30rpx;
				font-weight: 500;
				color: #333333;
				margin-top: 25rpx;
			}
			.kedouIntegral_button{
				width: 40%;
				height: 80rpx;
				line-height: 80rpx;
				background-color: #fe6600;
				text-align: center;
				// border: 1rpx solid #333333;
				border-radius: 40rpx;
				font-size: 30rpx;
				color: #ffffff;
				font-weight: 500;
			}
			.kedouIntegral_zhuan{
				width: 150rpx;
				height: 80rpx;
				line-height: 80rpx;
				border-radius: 40rpx 0 0 40rpx;
				text-align: center;
				position: absolute;
				top: 16rpx;
				right: 0;
				border: 1rpx solid #ebdede;
				border-right: none;
				font-size: 28rpx;
			}
		}
		.newTeam_title{
			width: 100%;
			box-sizing: border-box;
			padding:  40rpx 30rpx;
			font-size: 30rpx;
			font-weight: 800;
			color: #333333;
		}
		.newTeam_centent{
			width: 100%;
			background-color: #ffffff;
			box-sizing: border-box;
			padding: 0 24rpx;
			.newTeam_one{
				width: 100%;
				height: 120rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				border-bottom: 1rpx solid #f7f7f7;
				.newTeam_one_left{
					display: flex;
					align-items: center;
					image{
						width: 100rpx;
						height: 100rpx;
						border-radius: 50%;
					}
					.newTeam_one_leftActive{
						.leftActive_name{
							font-size: 30rpx;
							font-weight: 800;
							color: #333333;
							margin-top: 10rpx;
						}
						.leftActive_time{
							font-size: 24rpx;
							color: #666666;
						}
					}
				}
				.newTeam_one_right{
					font-size: 40rpx;
					font-weight: 500;
					color: #ff0000;
					margin-left: 15rpx;
				}
			}
		}
	}
</style>